package com.charm.businesshub.adapter

import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseViewHolder
import com.charm.businesshub.R
import com.charm.businesshub.entity.NewsListItemEntity
import com.charm.codes.imageLoad.XGlide
import com.charm.frameworkarou.recycleadapter.QuickRecyAdapter

/**
 * Created by tools on 2018/1/5.
 */
class NewsListAdapter(list: List<NewsListItemEntity>?) : QuickRecyAdapter<NewsListItemEntity>(list) {
    override fun convert(helper: BaseViewHolder?, item: NewsListItemEntity?) {
        var text = helper!!.getView<TextView>(R.id.title)
        var image = helper.getView<ImageView>(R.id.image)
        text.text = item!!.title
        if (item.imageUrls != null) {
            XGlide.getInstance().with(mContext)
                    .load(item.imageUrls!![0])
                    .placeholder(R.drawable.ic_launcher)
                    .error(R.drawable.ic_launcher)
                    .into(image)
                    .displayImage()
        }

    }

    override fun getLayoutResId(): Int {
        return R.layout.item_newslist
    }

}